﻿<!-- #Include File="Channel_Config.asp" -->
<!-- #Include File="../Include/Skin.asp" -->
<!-- #Include File="../Include/Channel.asp" -->
<!-- #Include File="../Include/Public.asp" -->
<%
Call GetChannel(ChannelID)

Public Function ShowChannelIndex(IsHtml)
	Tit=ChannelName&"首页"
	If ChannelMoban="" Then
		ChannelMoban = "Index.html"
	End If
	If ChannelSkinID="" Then
		ChannelSkinID = "DefaultSkin.css"
	End If
	HtmlContent = Channel_Index(ChannelMoban,ChannelSkinID)
	If IsHtml=True Then
		ShowChannelIndex = HtmlContent
	Else
		Response.Write HtmlContent
	End If
	If IsConn = False Then Call CloseConn()
End Function

Public Function ShowChannelList(Cid,IsHtml)
	Tit=ChannelTit&"列表"&ShowTit(Cid)
	If Mobanid="" Then
		Mobanid = "List.html"
	End If
	If Skinid="" Then
		Skinid = "DefaultSkin.css"
	End If
	HtmlContent = Channel_List(Cid,Mobanid,Skinid)
	If IsHtml=True Then
		ShowChannelList = HtmlContent
	Else
		Response.Write HtmlContent
	End If
	If IsConn = False Then Call CloseConn()
End Function

Public Function ShowChannelView(Vid,IsHtml)
	Tit=ChannelTit&"浏览"&ShowTit(Cid)&" - "&Title
	If Mobanid="" Then
		Mobanid = "View.html"
	End If
	If Skinid="" Then
		Skinid = "DefaultSkin.css"
	End If
	HtmlContent = Channel_View(Vid,Mobanid,Skinid)
	If IsHtml=True Then
		ShowChannelView = HtmlContent
	Else
		Response.Write HtmlContent
	End If
	If IsConn = False Then Call CloseConn()
End Function

Public Function ShowChannelSearch(Keyword,IsHtml)
	Tit=ChannelTit&"搜索 - "&Keyword
	If Mobanid="" Then
		Mobanid = "Search.html"
	End If
	If Skinid="" Then
		Skinid = "DefaultSkin.css"
	End If
	HtmlContent = Channel_Search(Keyword,Mobanid,Skinid)
	If IsHtml=True Then
		ShowChannelView = HtmlContent
	Else
		Response.Write HtmlContent
	End If
	If IsConn = False Then Call CloseConn()
End Function

Public Function Channel_Index(ChannelMoban,ChannelSkinID)
	Dim IndexContent
	HtmlContent = ChannelTemplate(ChannelMoban,ChannelSkinID,ChannelID)
	If Instr(HtmlContent,"【Repeat】") > 0 Then
		lablez = "【Repeat】"
	Else
		HtmlContent = ReplaceHtml(HtmlContent)
		HtmlContent = Html.ReadClass(HtmlContent)
		HtmlContent = Html.ReadClassName(HtmlContent)
		HtmlContent = Html.ReadChannelList(HtmlContent)
		HtmlContent = Html.ReadChannelPic(HtmlContent)
		HtmlContent = Html.ReadChannelFlash(HtmlContent)
		HtmlContent = Html.ReadChannelFlashqq(HtmlContent)
		HtmlContent = ReHtml(HtmlContent)
		Channel_Index = HtmlContent
		Exit Function
	End If
	regEx.Pattern = "【Repeat】([\s\S]*?)【\/Repeat】"
	Set Matches = regEx.Execute(HtmlContent)
	For Each Match In Matches
		Repeat = Match.SubMatches(0)
		HtmlContent = regEx.Replace(HtmlContent, "{$Repeat}")
		
		'得到每行显示的列数
		iCols = 1
		regEx.Pattern = "【Cols=(\d{1,2})】"
		Set Matches2 = regEx.Execute(Repeat)
		Repeat = regEx.Replace(Repeat,"")
		For Each Match2 In Matches2
			If Match2.SubMatches(0) > 1 Then iCols = Match2.SubMatches(0)
		Next
		Repeat2 = ""
		iClassID = 0
		Call Exec(rsClass,"select * from Class where ChannelID=" & ChannelID & " And ClassParent=0 Order By ClassOrder Asc,ClassID Asc",2)
		Do While Not rsClass.EOF
			IndexContent = Repeat
			Cid=Int(rsClass("ClassID"))
			ClassName=rsClass("ClassName")
			If ChannelIsCreateHtml = True Then
				mores=InstallDir & ChannelDir & "/"&rsClass("HtmlFileDir")&"Index"&ChannelHtmlExtName
			Else
				mores=InstallDir & ChannelDir & "/List.asp?ClassID="&Cid
			End If
			IndexContent = Replace(IndexContent,"{$ClassID}",Cid)
			IndexContent = Replace(IndexContent,"{$ClassName}",ClassName)
			IndexContent = Replace(IndexContent,"{$more}",mores)
			rsClass.MoveNext
			iClassID = iClassID + 1
			If iClassID Mod iCols = 0 And Not rsClass.EOF Then
				Repeat2 = Repeat2 & IndexContent
				If iCols > 1 Then Repeat2 = Repeat2 & "</tr><tr>"
			Else
				Repeat2 = Repeat2 & IndexContent
				If iCols > 1 Then Repeat2 = Repeat2 & "<td width='5'></td>"
			End If
		Loop
		rsClass.Close
		Set rsClass = Nothing
		HtmlContent = Replace(HtmlContent, "{$Repeat}", Repeat2)
	Next
	HtmlContent = Replace(HtmlContent,"{$ClassID}",Cid)
	HtmlContent = Replace(HtmlContent,"{$ListNum}",CLng(ChannelListNum(0)))
	HtmlContent = Replace(HtmlContent,"{$CuteNum}",CLng(ChannelCuteNum(0)))
	HtmlContent = Replace(HtmlContent,"{$ChannelID}",ChannelID)
	HtmlContent = Replace(HtmlContent,"{$ChannelTit}",ChannelTit)
	HtmlContent = Replace(HtmlContent,"{$ChannelDir}",ChannelDir)
	HtmlContent = Replace(HtmlContent,"{$ChannelName}",ChannelName)
	HtmlContent = Replace(HtmlContent,"{$ChannelUnit}",ChannelUnit)
	HtmlContent = ReplaceHtml(HtmlContent)
	HtmlContent = Html.ReadClass(HtmlContent)
	HtmlContent = Html.ReadClassName(HtmlContent)
	HtmlContent = Html.ReadChannelList(HtmlContent)
	HtmlContent = Html.ReadChannelPic(HtmlContent)
	HtmlContent = Html.ReadChannelFlash(HtmlContent)
	HtmlContent = Html.ReadChannelFlashqq(HtmlContent)
	HtmlContent = ReHtml(HtmlContent)
	Channel_Index = HtmlContent
End Function

Public Function Channel_List(Cid,Mobanid,Skinid)
	Dim ListContent
	If Trim(Request("MaxPerPage"))<>"" Then
		MaxPerPage = Code_CLng(Trim(Request("MaxPerPage")))
	Else
		If Is_Null(PageNum) = "" Or PageNum = 0 Then
			MaxPerPage = CLng(ChannelListNum(1))
		Else
			MaxPerPage = CLng(PageNum)
		End If
	End If
	If MaxPerPage <= 0 Then MaxPerPage = 20
	if Cid = "" Then
		Call Format_Redirect(InstallDir&ChannelDir)
		Response.End()
	End if
	HtmlContent = ChannelTemplate(Mobanid,Skinid,ChannelID)
	If Instr(HtmlContent,"[Repeat]") > 0 Then
		lablez = "[Repeat]"
	Else
		If ChannelIsCreateHtml = True Then
			mores = InstallDir & ChannelDir & "/" & HtmlFileDir & "Index" & ChannelHtmlExtName
		Else
			mores = InstallDir & ChannelDir & "/List.asp?ClassID=" & Cid
		End If
		HtmlContent = Replace(HtmlContent,"{$ClassID}",Cid)
		HtmlContent = Replace(HtmlContent,"{$more}",mores)
		HtmlContent = Replace(HtmlContent,"{$ClassName}", ClassNames)
		HtmlContent = ReplaceHtml(HtmlContent)
		HtmlContent = Html.ReadClass(HtmlContent)
		HtmlContent = Html.ReadClassName(HtmlContent)
		HtmlContent = Html.ReadChannelList(HtmlContent)
		HtmlContent = Html.ReadChannelPic(HtmlContent)
		HtmlContent = Html.ReadChannelFlash(HtmlContent)
		HtmlContent = Html.ReadChannelFlashqq(HtmlContent)
		HtmlContent = ReHtml(HtmlContent)
		Channel_List = HtmlContent
		Exit Function
	End If
	ListContent = CutFixContent(HtmlContent,lablez,"[/Repeat]",0)
	If ChannelIsCreateHtml = True Then
		mores = InstallDir & ChannelDir & "/" & HtmlFileDir & "Index" & ChannelHtmlExtName
	Else
		mores = InstallDir & ChannelDir & "/List.asp?ClassID=" & Cid
	End If
	sqlList = "Select * From " & ChannelDataName & " Where ChannelID=" & ChannelID & " and Hidden=" & WK_True & " And IsDelete=" & WK_False
	if ClassChildStr<>0 Then sqlList=sqlList&" and ClassID in (" & ClassChildStr & ")"
	sqlList=sqlList&" Order By OrderID Desc,ID Desc"
	Call Exe_Conn(rsList,sqlList,1)
	If rsList.BOF And rsList.EOF Then
		rsList.Close
		Set rsList = Nothing
		ListContents="对不起，没有任何" & ChannelTit & "！"
	Else
		totalPut = rsList.RecordCount
		If CurrentPage < 1 Then
			CurrentPage = 1
		End If
		If (CurrentPage - 1) * MaxPerPage > totalPut Then
			If (totalPut Mod MaxPerPage) = 0 Then
				CurrentPage = totalPut \ MaxPerPage
			Else
				CurrentPage = totalPut \ MaxPerPage + 1
			End If
		End If
		If CurrentPage > 1 Then
			If (CurrentPage - 1) * MaxPerPage < totalPut Then
				rsList.Move (CurrentPage - 1) * MaxPerPage
			Else
				CurrentPage = 1
			End If
		End If
		ji=1
		ListContents=ListContents&"<table width='100%' border='0' align='center' cellpadding='0' cellspacing='0'>" & VbCrlf
		Do While Not rsList.EOF
			sqlClassList="select * from Class where ChannelID=" & ChannelID & " And ClassID=" & rsList("ClassID") & " Order By ClassID,ClassOrder,ClassDepth Asc"
			Call Exe_Conn(rsClassList,sqlClassList,1)
			If rsClassList.eof And rsClassList.bof Then
				ClassName=""
			Else
				ClassAlt = rsClassList("ClassName")
				ClassName = rsClassList("ClassName")
				If ChannelIsCreateHtml = True Then
					ClassUrl = InstallDir & ChannelDir & "/" & rsClassList("HtmlFileDir") & "Index" & ChannelHtmlExtName
				Else
					ClassUrl = InstallDir & ChannelDir & "/List.asp?ClassID=" & rsClassList("ClassID")
				End If
			End If
			If ChannelIsCreateHtml = True Then
				HtmlFileName = ReadFileName(rsList("HtmlFileDate"), rsList("ID"), ChannelHtmlExtName, ChannelHtmlPrefix, ChannelHtmlForm, "")
				HtmlFileUrl = InstallDir & ChannelDir & "/" & rsClassList("HtmlFileDir") & ShowDatePath(rsList("HtmlFileDate"), ChannelHtmlPath) & HtmlFileName
			Else
				HtmlFileUrl = InstallDir & ChannelDir & "/View.asp?id=" & rsList("ID")
			End If
			rsClassList.Close
			Set rsClassList = Nothing
			Hits="<span id=""Hits""><script type=""text/javascript"">posthtm('" & InstallDir & ChannelDir & "/Hits.asp?Action=List&Hits=Hits','Hits','id=" & Vid & "');</script></span>"
			sTopic = GetIncInfo(rsList("IncludeInfo"))
			If ChannelIsCreateHtml = True Then
				sTitleAlt = ChannelTit & "标题：" & rsList("Title") & "&#13;&#10;发布时间：" & rsList("Tim")
			Else
				sTitleAlt = ChannelTit & "标题：" & rsList("Title") & "&#13;&#10;发布时间：" & rsList("Tim") & "&#13;&#10;阅览次数：" & rsList("Hits")
			End If
			If CLng(CuteNums) > 1 Then
				CuteNums = CuteNums
			Else
				CuteNums = ChannelCuteNum(1)
			End If
			If CLng(CuteNums)<>0 Then
				sTitle = Cuted(rsList("Title"), CLng(CuteNums))
			Else
				sTitle = rsList("Title")
			End If
			sTitle = GetTcolor(sTitle,rsList("Tcolor"),False)
			If rsList("Pic")<>"" Then
				Pic=rsList("Pic")
				Pic=Replace(Pic,"{$download_dir}",InstallDir & UploadSetting(1))
				Pic="<img src='" & Pic & "' width='" & ImageWidth & "' height='" & ImageHeight & "' border='0' />"
			Else
				Pic=InstallDir & "Images/no_pic.png"
				Pic=Replace(Pic,"{$download_dir}",InstallDir & UploadSetting(1))
				Pic="<img src='" & Pic & "' width='" & ImageWidth & "' height='" & ImageHeight & "' border='0' />"
			End If
			if ((ji-1) mod Columns = 0) Then ListContents=ListContents&"<tr>" & VbCrlf
			ListContents=ListContents&"<td width='*'>"
			ListContents=ListContents&ListContent
			ListContents=Replace(ListContents,"{$ClassUrl}",ClassUrl)
			ListContents=Replace(ListContents,"{$ClassAlt}",ClassAlt)
			ListContents=Replace(ListContents,"{$ClassName}",ClassName)
			ListContents=Replace(ListContents,"{$Topic}",sTopic)
			ListContents=Replace(ListContents,"{$Pic}",Pic)
			ListContents=Replace(ListContents,"{$TitleAlt}",sTitleAlt)
			ListContents=Replace(ListContents,"{$TitleUrl}",HtmlFileUrl)
			'替换{$Intro(InfoLength)}标签
			Dim strIntro
			regEx.Pattern = "\{\$Intro\((.*?)\)\}"
			Set Matches = regEx.Execute(ListContents)
			For Each Match In Matches
				arrTemp = Split(Match.SubMatches(0), ",")
				If UBound(arrTemp) <> 0 Then
					strIntro= "函数式标签：{$Intro(参数列表)}的参数个数不对。请检查模板中的此标签。"
			
				Else
					If Code_CLng(arrTemp(0))>0 then
						strIntro = GetSubStr(NoHtml(rsList("Intro")),Code_CLng(arrTemp(0)),False)
					Else
						strIntro = NoHtml(rsList("Intro"))
					End IF
				End If
				ListContents = Replace(ListContents, Match.Value, strIntro)
			Next
			'替换{$Content(InfoLength)}标签
			Dim strContent
			regEx.Pattern = "\{\$Content\((.*?)\)\}"
			Set Matches = regEx.Execute(ListContents)
			For Each Match In Matches
				arrTemp = Split(Match.SubMatches(0), ",")
				If UBound(arrTemp) <> 0 Then
					strContent= "函数式标签：{$Content(参数列表)}的参数个数不对。请检查模板中的此标签。"
			
				Else
					If Code_CLng(arrTemp(0))>0 then
						strContent = GetSubStr(NoHtml(rsList("Content")),Code_CLng(arrTemp(0)),False)
					Else
						strContent = NoHtml(rsList("Content"))
					End IF
				End If
				ListContents = Replace(ListContents, Match.Value, strContent)
			Next
			labelRuleField = "\{\$([\s\S]*?)\}"
			regEx.Pattern = labelRuleField
			Set Matches = regEx.Execute(ListContents)
			For Each Match In Matches
				fieldNameArr = RegExpReplace(Match.SubMatches(0),"[\s]+",chr(32))
				fieldNameArr = trim(fieldNameArr)
				m = instr(fieldNameArr,chr(32))
				If  m > 0 then
					fieldName = left(fieldNameArr,m - 1)
					fieldArr = right(fieldNameArr,len(fieldNameArr) - m)
				Else
					fieldName = fieldNameArr
					fieldArr = ""
				End If
				Select Case fieldName
				Case "Title"
					namelen = ParseArr(fieldArr)("len")
					if not IsNul(namelen) then
						namelen=cint(namelen)
						if len(sTitle)>namelen then sTitle=GetSubStr(sTitle,namelen,False)
					end if
					ListContents = Replace(ListContents,Match.value,sTitle)
				Case "Date"
					timestyle = ParseArr(fieldArr)("style") : if IsNul(timestyle) then timestyle = "m-d"
					Select Case timestyle
						Case "yy-m-d"
							ListContents = Replace(ListContents,Match.value,FormatDate(rsList("Tim"),1))
						Case "y-m-d"
							ListContents = Replace(ListContents,Match.value,FormatDate(rsList("Tim"),2))
						Case "m-d"
							ListContents = Replace(ListContents,Match.value,FormatDate(rsList("Tim"),3))
						Case "yy/m/d"
							ListContents = Replace(ListContents,Match.value,FormatDate(rsList("Tim"),9))
						Case "y/m/d"
							ListContents = Replace(ListContents,Match.value,FormatDate(rsList("Tim"),10))
						Case "m/d"
							ListContents = Replace(ListContents,Match.value,FormatDate(rsList("Tim"),11))
					End Select
				Case fieldName
					SqlFieldSet = "SELECT * FROM [FieldSet] WHERE Field='"& fieldName &"' AND ChannelID="& ChannelID &" AND Recycle<>1 ORDER BY OrderNum ASC"
					Call Exec(RsFieldSet,SqlFieldSet,2)
					If RsFieldSet.BOF And RsFieldSet.EOF Then
						RsFieldSet.Close
						Set RsFieldSet = Nothing
					Else
						Pv_FieldType = RsFieldSet("FieldType")
						RsFieldSet.Close
						Set RsFieldSet = Nothing
						namelen = ParseArr(fieldArr)("len")
						sfieldName = rsList(fieldName)
						if not IsNul(sfieldName) then
							If Pv_FieldType="checkbox" Then
								ListContents = Replace(ListContents,Match.value,left(sfieldName,len(sfieldName)-1))
							Else
								if not IsNul(namelen) then
									namelen=cint(namelen)
									if len(sfieldName)>namelen then sfieldName=GetSubStr(sfieldName,namelen,False)
								end if
								ListContents = Replace(ListContents,Match.value,sfieldName)
							End If
						else
							ListContents = Replace(ListContents,Match.value,"")
						end if
					End If
				End Select
			Next
			Set Matches = nothing
			ListContents=Replace(ListContents,"{$Intro}",rsList("Intro"))
			ListContents=Replace(ListContents,"{$Content}",rsList("Content"))
			ListContents=Replace(ListContents,"{$Hits}",Hits)
			ListContents=Replace(ListContents,"{$Keyes}",rsList("Keyes"))
			ListContents=Replace(ListContents,"{$Inputer}",rsList("Inputer"))
			ListContents=Replace(ListContents,"{$Author}",rsList("Author"))
			ListContents=Replace(ListContents,"{$Subtitle}",rsList("Subtitle"))
			ListContents=Replace(ListContents,"{$Subheading}",rsList("Subheading"))
			Sql="select * from CopyFrom where ChannelID=" & ChannelID & " and SourceName='" & rsList("CopyFrom") & "'"
			Call Exe_Conn(Rs,Sql,3)
			If Rs.BOF And Rs.EOF Then
				Rs.Close
				Set Rs = Nothing
				CopyFrom = "<a href=""" & SiteUrl & """ target=""_blank"">" & rsList("CopyFrom") & "</a>"
			Else
				CopyFrom = "<a href=""" & Rs("SourceUrl") & """ target=""_blank"">" & Rs("SourceName") & "</a>"
				Rs.Close
				Set Rs = Nothing
			End If
			ListContents=Replace(ListContents,"{$CopyFrom}",CopyFrom)
			ListContents=ListContents&"</td>" & VbCrlf
			if (ji mod Columns = 0) Then ListContents=ListContents&"</tr>" & VbCrlf
			ji=ji+1
			iCount = iCount + 1
			If iCount >= MaxPerPage Then Exit Do
			rsList.MoveNext
		Loop
		rsList.Close
		Set rsList = Nothing
		if totalPut < Columns Then ListContents=ListContents&"</tr>" & VbCrlf
		if (totalPut mod Columns = 1) Then ListContents=ListContents&"</tr>" & VbCrlf
		ListContents=ListContents&"</table>"
		If ChannelIsCreateHtml = True Then
			Body=ShowPage_Html(InstallDir & ChannelDir & "/" & HtmlFileDir, 0, ChannelHtmlExtName, "", totalPut, MaxPerPage, CurrentPage, True, True, ChannelUnit & ChannelTit)
		Else
			Body=ShowPage(strFileName, totalPut, MaxPerPage, CurrentPage, True, True, ChannelUnit & ChannelTit, True)
		End If
	End If
	HtmlContent = Replace(HtmlContent,lablez & ListContent&"[/Repeat]",ListContents)
	HtmlContent = Replace(HtmlContent,"{$ClassID}",Cid)
	HtmlContent = Replace(HtmlContent,"{$more}",mores)
	HtmlContent = Replace(HtmlContent,"{$ClassName}", ClassNames)
	HtmlContent = Replace(HtmlContent,"{$ShowPage}",Body)
	HtmlContent = Replace(HtmlContent,"{$ChannelID}",ChannelID)
	HtmlContent = Replace(HtmlContent,"{$ChannelTit}",ChannelTit)
	HtmlContent = Replace(HtmlContent,"{$ChannelDir}",ChannelDir)
	HtmlContent = Replace(HtmlContent,"{$ChannelName}",ChannelName)
	HtmlContent = Replace(HtmlContent,"{$ChannelUnit}",ChannelUnit)
	if not IsNul(MetaKeyWord) then
		HtmlContent = Replace(HtmlContent,"{$MetaKeyWord}",MetaKeyWord)
	else
		HtmlContent = Replace(HtmlContent,"{$MetaKeyWord}","")
	end if
	if not IsNul(MetaDescript) then
		HtmlContent = Replace(HtmlContent,"{$MetaDescript}",MetaDescript)
	else
		HtmlContent = Replace(HtmlContent,"{$MetaDescript}","")
	end if
	HtmlContent = ReplaceHtml(HtmlContent)
	HtmlContent = Html.ReadClass(HtmlContent)
	HtmlContent = Html.ReadClassName(HtmlContent)
	HtmlContent = Html.ReadChannelList(HtmlContent)
	HtmlContent = Html.ReadChannelPic(HtmlContent)
	HtmlContent = Html.ReadChannelFlash(HtmlContent)
	HtmlContent = Html.ReadChannelFlashqq(HtmlContent)
	HtmlContent = ReHtml(HtmlContent)
	Channel_List = HtmlContent
End Function

Public Function Channel_View(Vid,Mobanid,Skinid)
	Dim StrUploadFilesUrl
	if Vid="" Then
		Call Format_Redirect(InstallDir&ChannelDir)
		Response.End()
	End if
	HtmlContent = ChannelTemplate(Mobanid,Skinid,ChannelID)
	'Call Exec("","Update " & ChannelDataName & " Set Hits=Hits+1 Where ChannelID=" & ChannelID & " and Hidden=" & WK_True & " And IsDelete=" & WK_False & " and id=" & Vid,0)
	sqlView = "Select * From " & ChannelDataName & " Where ChannelID=" & ChannelID & " and Hidden=" & WK_True & " And IsDelete=" & WK_False & " and id=" & Vid & " Order By ClassID,OrderID,ID Asc"
	Call Exe_Conn(rsView,sqlView,1)
	If rsView.BOF And rsView.EOF Then
		rsView.Close
		Set rsView = Nothing
		Call Format_Redirect(InstallDir&ChannelDir)
		Response.End()
	Else
		sqlClassView="select * from Class where ChannelID=" & ChannelID & " And ClassID=" & rsView("ClassID") & " Order By ClassID,ClassOrder,ClassDepth Asc"
		Call Exe_Conn(rsClassView,sqlClassView,1)
		If rsClassView.eof And rsClassView.bof Then
			ClassName = ""
		Else
			Cid = rsClassView("ClassID")
			HtmlFileDir = rsClassView("HtmlFileDir")
			ClassAlt = rsClassView("ClassName")
			ClassName = rsClassView("ClassName")
			If ChannelIsCreateHtml = True Then
				ClassUrl = InstallDir & ChannelDir & "/" & HtmlFileDir & "Index" & ChannelHtmlExtName
			Else
				ClassUrl = InstallDir & ChannelDir & "/List.asp?ClassID=" & rsClassView("ClassID")
			End If
			rsClassView.Close
			Set rsClassView = Nothing
		End If
		If ChannelIsCreateHtml = True Then
			HtmlFileName = ReadFileName(rsView("HtmlFileDate"), rsView("ID"), ChannelHtmlExtName, ChannelHtmlPrefix, ChannelHtmlForm, "")
			HtmlFileUrl = InstallDir & ChannelDir & "/" & HtmlFileDir & ShowDatePath(rsView("HtmlFileDate"), ChannelHtmlPath) & HtmlFileName
		Else
			HtmlFileUrl = InstallDir & ChannelDir & "/View.asp?id=" & rsView("ID")
		End If
		Cid = rsView("ClassID")
		sTopic = GetIncInfo(rsView("IncludeInfo"))
		If ChannelIsCreateHtml = True Then
			sTitleAlt = ChannelTit & "标题：" & rsView("Title") & "&#13;&#10;发布时间：" & rsView("Tim")
		Else
			sTitleAlt = ChannelTit & "标题：" & rsView("Title") & "&#13;&#10;发布时间：" & rsView("Tim") & "&#13;&#10;阅览次数：" & rsView("Hits")
		End If
		If CLng(ChannelCuteNum(2))<>0 Then
			sTitle = Cuted(rsView("Title"), ChannelCuteNum(2))
		Else
			sTitle = rsView("Title")
		End If
		sTitle = GetTcolor(sTitle,rsView("Tcolor"),False)
		PageTitle = rsView("PageTitle")
		If rsView("UploadFiles")<>"" Then
			StrUploadFilesUrl=Trim(rsView("UploadFiles"))
			if Instr(StrUploadFilesUrl,"@@@") >0 Then
				StrUploadFilesUrl=Split(StrUploadFilesUrl,"@@@")
				for i=0 to Ubound(StrUploadFilesUrl)
					Pic=Pic&"<img src='" & Replace(StrUploadFilesUrl(i),"{$download_dir}",InstallDir & UploadSetting(1)) & "' width='" & ChannelPicWidth & "' height='" & ChannelPicHeight & "' border='0' />"
				Next
			else
				Pic="<img src='" & Replace(StrUploadFilesUrl,"{$download_dir}",InstallDir & UploadSetting(1)) & "' width='" & ChannelPicWidth & "' height='" & ChannelPicHeight & "' border='0' />"
			end if
		Else
			Pic=""
		End If
		PaginationType=rsView("PaginationType")
		MaxCharPerPage=rsView("MaxCharPerPage")
		If rsView("LinkUrl") <> "" And rsView("LinkUrl") <> "http://" Then
			Content="<script type='text/javascript'>window.location.href='" & rsView("LinkUrl") & "';</script>"
		Else
			Select Case PaginationType
				Case 0    '不分页显示
					Content=Replace(rsView("Content"),"{$download_dir}",InstallDir & UploadSetting(1))
				Case 1    '自动分页显示
					Content=AutoPagination(Replace(rsView("Content"),"{$download_dir}",InstallDir & UploadSetting(1)),MaxCharPerPage,HtmlFileUrl)
				Case 2    '手动分页显示
					Content=ManualPagination(Replace(rsView("Content"),"{$download_dir}",InstallDir & UploadSetting(1)),HtmlFileUrl)
			End Select
		End If
		Tim=rsView("Tim")
		Hits="<span id=""Hits""><script type=""text/javascript"">posthtm('" & InstallDir & ChannelDir & "/Hits.asp?Hits=Hits','Hits','id=" & Vid & "');</script></span>"
		Keyes=rsView("Keyes")
		Inputer=rsView("Inputer")
		Author=rsView("Author")
		Subtitle=rsView("Subtitle")
		Subheading=rsView("Subheading")
		Sql="select * from CopyFrom where ChannelID=" & ChannelID & " and SourceName='" & rsView("CopyFrom") & "'"
		Call Exe_Conn(Rs,Sql,3)
		If Rs.BOF And Rs.EOF Then
			Rs.Close
			Set Rs = Nothing
			CopyFrom = "<a href=""" & SiteUrl & """ target=""_blank"">" & rsView("CopyFrom") & "</a>"
		Else
			CopyFrom = "<a href=""" & Rs("SourceUrl") & """ target=""_blank"">" & Rs("SourceName") & "</a>"
			Rs.Close
			Set Rs = Nothing
		End If
		ContentArr=rsView("Content")
		Intro=rsView("Intro")
		HtmlFileDate=rsView("HtmlFileDate")
		SqlFieldSet = "SELECT * FROM [FieldSet] WHERE ChannelID="& ChannelID &" AND Recycle<>1 ORDER BY OrderNum ASC"
		Call Exec(RsFieldSet,SqlFieldSet,2)
		Do While Not(RsFieldSet.Eof)
			Pv_Field = RsFieldSet("Field")
			If RsFieldSet("FieldType")="checkbox" Then
				HtmlContent = Replace(HtmlContent,"{$" & Pv_Field & "}",left(rsView(Pv_Field),len(rsView(Pv_Field))-1))
			Else
				HtmlContent = Replace(HtmlContent,"{$" & Pv_Field & "}",rsView(Pv_Field))
			End If
			RsFieldSet.MoveNext
		Loop
		sqlUpView="select * from " & ChannelDataName & " where ChannelID=" & ChannelID & " And ClassID=" & rsView("ClassID") & " And id<" & Vid & " and Hidden=" & WK_True & " And IsDelete=" & WK_False & " Order By id Desc"
		Call Exe_Conn(rsUpView,sqlUpView,1)
		If rsUpView.eof And rsUpView.bof Then
			About_Up = "上一" & ChannelUnit & ChannelTit & "：没有找到上一" & ChannelUnit
		Else
			If ChannelIsCreateHtml = True Then
				HtmlFileName = ReadFileName(rsUpView("HtmlFileDate"), rsUpView("ID"), ChannelHtmlExtName, ChannelHtmlPrefix, ChannelHtmlForm, "")
				About_Up = "上一" & ChannelUnit & ChannelTit & "：<a href='" & InstallDir & ChannelDir & "/" & HtmlFileDir & ShowDatePath(rsUpView("HtmlFileDate"), ChannelHtmlPath) & HtmlFileName & "'>" & rsUpView("Title") & "</a>"
			Else
				About_Up = "上一" & ChannelUnit & ChannelTit & "：<a href='" & InstallDir & ChannelDir & "/View.asp?id=" & rsUpView("ID") & "'>" & rsUpView("Title") & "</a>"
			End If
			rsUpView.Close
			Set rsUpView = Nothing
		End If
		sqlDownView="select * from " & ChannelDataName & " where ChannelID=" & ChannelID & " And ClassID=" & rsView("ClassID") & " And id>" & Vid & " and Hidden=" & WK_True & " And IsDelete=" & WK_False & " Order By id Asc"
		Call Exe_Conn(rsDownView,sqlDownView,1)
		If rsDownView.eof And rsDownView.bof Then
			About_Down = "下一" & ChannelUnit & ChannelTit & "：没有找到下一" & ChannelUnit
		Else
			If ChannelIsCreateHtml = True Then
				HtmlFileName = ReadFileName(rsDownView("HtmlFileDate"), rsDownView("ID"), ChannelHtmlExtName, ChannelHtmlPrefix, ChannelHtmlForm, "")
				About_Down = "下一" & ChannelUnit & ChannelTit & "：<a href='" & InstallDir & ChannelDir & "/" & HtmlFileDir & ShowDatePath(rsDownView("HtmlFileDate"), ChannelHtmlPath) & HtmlFileName & "'>" & rsDownView("Title") & "</a>"
			Else
				About_Down = "下一" & ChannelUnit & ChannelTit & "：<a href='" & InstallDir & ChannelDir & "/View.asp?id=" & rsDownView("ID") & "'>" & rsDownView("Title") & "</a>"
			End If
			rsDownView.Close
			Set rsDownView = Nothing
		End If
		rsView.Close
		Set rsView = Nothing
	End If
	HtmlContent = Replace(HtmlContent,"{$ClassID}",Cid)
	HtmlContent = Replace(HtmlContent,"{$more}",mores)
	HtmlContent = Replace(HtmlContent,"{$ClassUrl}",ClassUrl)
	HtmlContent = Replace(HtmlContent,"{$ClassAlt}",ClassAlt)
	HtmlContent = Replace(HtmlContent,"{$ClassName}", ClassName)
	HtmlContent = Replace(HtmlContent,"{$Topic}",sTopic)
	labelRuleField = "\{\$([\s\S]*?)\}"
	regEx.Pattern = labelRuleField
	Set Matches = regEx.Execute(HtmlContent)
	For Each Match In Matches
		fieldNameArr = RegExpReplace(Match.SubMatches(0),"[\s]+",chr(32))
		fieldNameArr = trim(fieldNameArr)
		m = instr(fieldNameArr,chr(32))
		If  m > 0 then
			fieldName = left(fieldNameArr,m - 1)
			fieldArr = right(fieldNameArr,len(fieldNameArr) - m)
		Else
			fieldName = fieldNameArr
			fieldArr = ""
		End If
		Select Case fieldName
		Case "Title"
			namelen = ParseArr(fieldArr)("len")
			if not IsNul(namelen) then
				namelen=cint(namelen)
				if len(sTitle)>namelen then sTitle=GetSubStr(sTitle,namelen,False)
			end if
			if PaginationType=1 Or PaginationType=2 then
				arrContent = Split(ContentArr, "[NextPage]")
				For I = 0 To UBound(arrContent)
					If Not IsNul(PageTitle) Then
						PageTitleArr=Split(PageTitle,"§")
						If CurrentPage-1<=Ubound(PageTitleArr) Then
							HtmlContent = Replace(HtmlContent,Match.value,PageTitleArr(CurrentPage-1))
						Else
							HtmlContent = Replace(HtmlContent,Match.value,sTitle)
						End If
					Else
							HtmlContent = Replace(HtmlContent,Match.value,sTitle)
					End IF
				Next
			else
				HtmlContent = Replace(HtmlContent,Match.value,sTitle)
			end if
		Case "Date"
			timestyle = ParseArr(fieldArr)("style") : if IsNul(timestyle) then timestyle = "m-d"
			Select Case timestyle
				Case "yy-m-d"
					HtmlContent = Replace(HtmlContent,Match.value,FormatDate(Tim,1))
				Case "y-m-d"
					HtmlContent = Replace(HtmlContent,Match.value,FormatDate(Tim,2))
				Case "m-d"
					HtmlContent = Replace(HtmlContent,Match.value,FormatDate(Tim,3))
				Case "yy/m/d"
					HtmlContent = Replace(HtmlContent,Match.value,FormatDate(Tim,9))
				Case "y/m/d"
					HtmlContent = Replace(HtmlContent,Match.value,FormatDate(Tim,10))
				Case "m/d"
					HtmlContent = Replace(HtmlContent,Match.value,FormatDate(Tim,11))
			End Select
		End Select
	Next
	Set Matches = nothing
	HtmlContent = Replace(HtmlContent,"{$Pic}",Pic)
	HtmlContent = Replace(HtmlContent,"{$TitleAlt}",sTitleAlt)
	HtmlContent = Replace(HtmlContent,"{$TitleUrl}",HtmlFileUrl)
	'替换{$Intro(InfoLength)}标签
	Dim strIntro
	regEx.Pattern = "\{\$Intro\((.*?)\)\}"
	Set Matches = regEx.Execute(HtmlContent)
	For Each Match In Matches
		arrTemp = Split(Match.SubMatches(0), ",")
		If UBound(arrTemp) <> 0 Then
			strIntro= "函数式标签：{$Intro(参数列表)}的参数个数不对。请检查模板中的此标签。"
	
		Else
			If Code_CLng(arrTemp(0))>0 then
				strIntro = GetSubStr(NoHtml(Intro),Code_CLng(arrTemp(0)),False)
			Else
				strIntro = NoHtml(Intro)
			End IF
		End If
		HtmlContent = Replace(HtmlContent, Match.Value, strIntro)
	Next
	'替换{$Content(InfoLength)}标签
	Dim strContent
	regEx.Pattern = "\{\$Content\((.*?)\)\}"
	Set Matches = regEx.Execute(HtmlContent)
	For Each Match In Matches
		arrTemp = Split(Match.SubMatches(0), ",")
		If UBound(arrTemp) <> 0 Then
			strContent= "函数式标签：{$Content(参数列表)}的参数个数不对。请检查模板中的此标签。"
	
		Else
			If Code_CLng(arrTemp(0))>0 then
				strContent = GetSubStr(NoHtml(Content),Code_CLng(arrTemp(0)),False)
			Else
				strContent = NoHtml(Content)
			End IF
		End If
		HtmlContent = Replace(HtmlContent, Match.Value, strContent)
	Next
	HtmlContent = Replace(HtmlContent,"{$Intro}",Intro)
	HtmlContent = Replace(HtmlContent,"{$Content}",Content)
	HtmlContent = Replace(HtmlContent,"{$Hits}",Hits)
	HtmlContent = Replace(HtmlContent,"{$Keyes}",Keyes)
	HtmlContent = Replace(HtmlContent,"{$Inputer}",Inputer)
	HtmlContent = Replace(HtmlContent,"{$Author}",Author)
	HtmlContent = Replace(HtmlContent,"{$Subtitle}",Subtitle)
	HtmlContent = Replace(HtmlContent,"{$Subheading}",Subheading)
	HtmlContent = Replace(HtmlContent,"{$CopyFrom}",CopyFrom)
	HtmlContent = Replace(HtmlContent,"{$About_Up}",About_Up)
	HtmlContent = Replace(HtmlContent,"{$About_Down}",About_Down)
	HtmlContent = Replace(HtmlContent,"{$ChannelID}",ChannelID)
	HtmlContent = Replace(HtmlContent,"{$ChannelTit}",ChannelTit)
	HtmlContent = Replace(HtmlContent,"{$ChannelDir}",ChannelDir)
	HtmlContent = Replace(HtmlContent,"{$ChannelName}",ChannelName)
	HtmlContent = Replace(HtmlContent,"{$ChannelUnit}",ChannelUnit)
	if not IsNul(SEOTitle) then
		HtmlContent = Replace(HtmlContent,"{$SEOTitle}",SEOTitle)
	else
		HtmlContent = Replace(HtmlContent,"{$SEOTitle}","")
	end if
	if not IsNul(SEOKeyWord) then
		HtmlContent = Replace(HtmlContent,"{$SEOKeyWord}",SEOKeyWord)
	else
		HtmlContent = Replace(HtmlContent,"{$SEOKeyWord}","")
	end if
	if not IsNul(SEODescript) then
		HtmlContent = Replace(HtmlContent,"{$SEODescript}",SEODescript)
	else
		HtmlContent = Replace(HtmlContent,"{$SEODescript}","")
	end if
	HtmlContent = ReplaceHtml(HtmlContent)
	HtmlContent = Html.ReadClass(HtmlContent)
	HtmlContent = Html.ReadClassName(HtmlContent)
	HtmlContent = Html.ReadChannelList(HtmlContent)
	HtmlContent = Html.ReadChannelPic(HtmlContent)
	HtmlContent = Html.ReadChannelFlash(HtmlContent)
	HtmlContent = Html.ReadChannelFlashqq(HtmlContent)
	HtmlContent = ReHtml(HtmlContent)
	Channel_View = HtmlContent
End Function

Public Function Channel_Search(Keyword,Mobanid,Skinid)
	If Keyword<>"" Then
		Dim SearchContent
		If Trim(Request("MaxPerPage"))<>"" Then
			MaxPerPage = Code_CLng(Trim(Request("MaxPerPage")))
		Else
			MaxPerPage = CLng(ChannelListNum(1))
		End If
		If MaxPerPage <= 0 Then MaxPerPage = 20
		HtmlContent = ChannelTemplate(Mobanid,Skinid,ChannelID)
		If Instr(HtmlContent,"[Repeat]") > 0 Then
			lablez = "[Repeat]"
		Else
			HtmlContent = Replace(HtmlContent,"{$ClassName}", ClassNames)
			HtmlContent = ReplaceHtml(HtmlContent)
			HtmlContent = Html.ReadClass(HtmlContent)
			HtmlContent = Html.ReadClassName(HtmlContent)
			HtmlContent = Html.ReadChannelList(HtmlContent)
			HtmlContent = Html.ReadChannelPic(HtmlContent)
			HtmlContent = Html.ReadChannelFlash(HtmlContent)
			HtmlContent = Html.ReadChannelFlashqq(HtmlContent)
			HtmlContent = ReHtml(HtmlContent)
			Channel_Search = HtmlContent
			Exit Function
		End If
		SearchContent = CutFixContent(HtmlContent,lablez,"[/Repeat]",0)
		sqlList = "Select * From " & ChannelDataName & " Where ChannelID=" & ChannelID & " and Hidden=" & WK_True & " And IsDelete=" & WK_False & " and Title like '%" & Keyword & "%'"
		sqlList=sqlList&" Order By OrderID Desc,ID Desc"
		Call Exe_Conn(rsList,sqlList,1)
		If rsList.BOF And rsList.EOF Then
			rsList.Close
			Set rsList = Nothing
			SearchContents = SearchContents & "对不起，关键字&nbsp;<font color='red'>"&Keyword&"</font>&nbsp;没有任何" & ChannelTit & "！"
		Else
			totalPut = rsList.RecordCount
			If CurrentPage < 1 Then
				CurrentPage = 1
			End If
			If (CurrentPage - 1) * MaxPerPage > totalPut Then
				If (totalPut Mod MaxPerPage) = 0 Then
					CurrentPage = totalPut \ MaxPerPage
				Else
					CurrentPage = totalPut \ MaxPerPage + 1
				End If
			End If
			If CurrentPage > 1 Then
				If (CurrentPage - 1) * MaxPerPage < totalPut Then
					rsList.Move (CurrentPage - 1) * MaxPerPage
				Else
					CurrentPage = 1
				End If
			End If
			ji=1
			SearchContents=SearchContents&"<table width='100%' border='0' align='center' cellpadding='0' cellspacing='0'>" & VbCrlf
			Do While Not rsList.EOF
				sqlClassList="select * from Class where ChannelID=" & ChannelID & " And ClassID=" & rsList("ClassID") & " Order By ClassID,ClassOrder,ClassDepth Asc"
				Call Exe_Conn(rsClassList,sqlClassList,1)
				If rsClassList.eof And rsClassList.bof Then
					ClassName=""
				Else
					ClassAlt = rsClassList("ClassName")
					ClassName = rsClassList("ClassName")
					If ChannelIsCreateHtml = True Then
						ClassUrl = InstallDir & ChannelDir & "/" & rsClassList("HtmlFileDir") & "Index" & ChannelHtmlExtName
					Else
						ClassUrl = InstallDir & ChannelDir & "/List.asp?ClassID=" & rsClassList("ClassID")
					End If
				End If
				If ChannelIsCreateHtml = True Then
					HtmlFileName = ReadFileName(rsList("HtmlFileDate"), rsList("ID"), ChannelHtmlExtName, ChannelHtmlPrefix, ChannelHtmlForm, "")
					HtmlFileUrl = InstallDir & ChannelDir & "/" & rsClassList("HtmlFileDir") & ShowDatePath(rsList("HtmlFileDate"), ChannelHtmlPath) & HtmlFileName
				Else
					HtmlFileUrl = InstallDir & ChannelDir & "/View.asp?id=" & rsList("ID")
				End If
				rsClassList.Close
				Set rsClassList = Nothing
				Hits="<span id=""Hits""><script type=""text/javascript"">posthtm('" & InstallDir & ChannelDir & "/Hits.asp?Action=List&Hits=Hits','Hits','id=" & Vid & "');</script></span>"
				sTopic = GetIncInfo(rsList("IncludeInfo"))
				If ChannelIsCreateHtml = True Then
					sTitleAlt = ChannelTit & "标题：" & rsList("Title") & "&#13;&#10;发布时间：" & rsList("Tim")
				Else
					sTitleAlt = ChannelTit & "标题：" & rsList("Title") & "&#13;&#10;发布时间：" & rsList("Tim") & "&#13;&#10;阅览次数：" & rsList("Hits")
				End If
				If CLng(CuteNums) > 1 Then
					CuteNums = 50
				Else
					CuteNums = ChannelCuteNum(1)
				End If
				If CLng(CuteNums)<>0 Then
					sTitle = Cuted(rsList("Title"), CLng(CuteNums))
				Else
					sTitle = rsList("Title")
				End If
				sTitle = GetTcolor(sTitle,rsList("Tcolor"),False)
				IsPic = rsList("IsPic")
				If rsList("Pic")<>"" Then
					Pic=rsList("Pic")
					Pic=Replace(Pic,"{$download_dir}",InstallDir & UploadSetting(1))
					Pic="<img src='" & Pic & "' width='" & ImageWidth & "' height='" & ImageHeight & "' border='0' />"
				Else
					Pic=InstallDir & "Images/no_pic.png"
					Pic=Replace(Pic,"{$download_dir}",InstallDir & UploadSetting(1))
					Pic="<img src='" & Pic & "' width='" & ImageWidth & "' height='" & ImageHeight & "' border='0' />"
				End If
				if ((ji-1) mod 1 = 0) Then SearchContents=SearchContents&"<tr>" & VbCrlf
				SearchContents=SearchContents&"<td width='*'>"
				SearchContents=SearchContents&SearchContent
				SearchContents=Replace(SearchContents,"{$ClassUrl}",ClassUrl)
				SearchContents=Replace(SearchContents,"{$ClassAlt}",ClassAlt)
				SearchContents=Replace(SearchContents,"{$ClassName}",ClassName)
				SearchContents=Replace(SearchContents,"{$Topic}",sTopic)
				SearchContents=Replace(SearchContents,"{$IsPic}",IsPic)
				SearchContents=Replace(SearchContents,"{$Pic}",Pic)
				SearchContents=Replace(SearchContents,"{$TitleAlt}",sTitleAlt)
				SearchContents=Replace(SearchContents,"{$TitleUrl}",HtmlFileUrl)
				'替换{$Intro(InfoLength)}标签
				Dim strIntro
				regEx.Pattern = "\{\$Intro\((.*?)\)\}"
				Set Matches = regEx.Execute(SearchContents)
				For Each Match In Matches
					arrTemp = Split(Match.SubMatches(0), ",")
					If UBound(arrTemp) <> 0 Then
						strIntro= "函数式标签：{$Intro(参数列表)}的参数个数不对。请检查模板中的此标签。"
				
					Else
						If Code_CLng(arrTemp(0))>0 then
							strIntro = GetSubStr(NoHtml(rsList("Intro")),Code_CLng(arrTemp(0)),False)
						Else
							strIntro = NoHtml(rsList("Intro"))
						End IF
					End If
					SearchContents = Replace(SearchContents, Match.Value, strIntro)
				Next
				'替换{$Content(InfoLength)}标签
				Dim strContent
				regEx.Pattern = "\{\$Content\((.*?)\)\}"
				Set Matches = regEx.Execute(SearchContents)
				For Each Match In Matches
					arrTemp = Split(Match.SubMatches(0), ",")
					If UBound(arrTemp) <> 0 Then
						strContent= "函数式标签：{$Content(参数列表)}的参数个数不对。请检查模板中的此标签。"
				
					Else
						If Code_CLng(arrTemp(0))>0 then
							strContent = GetSubStr(NoHtml(rsList("Content")),Code_CLng(arrTemp(0)),False)
						Else
							strContent = NoHtml(rsList("Content"))
						End IF
					End If
					SearchContents = Replace(SearchContents, Match.Value, strContent)
				Next
				labelRuleField = "\{\$([\s\S]*?)\}"
				regEx.Pattern = labelRuleField
				Set Matches = regEx.Execute(SearchContents)
				For Each Match In Matches
					fieldNameArr = RegExpReplace(Match.SubMatches(0),"[\s]+",chr(32))
					fieldNameArr = trim(fieldNameArr)
					m = instr(fieldNameArr,chr(32))
					If  m > 0 then
						fieldName = left(fieldNameArr,m - 1)
						fieldArr = right(fieldNameArr,len(fieldNameArr) - m)
					Else
						fieldName = fieldNameArr
						fieldArr = ""
					End If
					Select Case fieldName
					Case "Title"
						namelen = ParseArr(fieldArr)("len")
						if not IsNul(namelen) then
							namelen=cint(namelen)
							if len(sTitle)>namelen then sTitle=GetSubStr(sTitle,namelen,False)
						end if
							SearchContents = Replace(SearchContents,Match.value,sTitle)
					Case "Date"
						timestyle = ParseArr(fieldArr)("style") : if IsNul(timestyle) then timestyle = "m-d"
						Select Case timestyle
							Case "yy-m-d"
								SearchContents = Replace(SearchContents,Match.value,FormatDate(rsList("Tim"),1))
							Case "y-m-d"
								SearchContents = Replace(SearchContents,Match.value,FormatDate(rsList("Tim"),2))
							Case "m-d"
								SearchContents = Replace(SearchContents,Match.value,FormatDate(rsList("Tim"),3))
							Case "yy/m/d"
								SearchContents = Replace(SearchContents,Match.value,FormatDate(rsList("Tim"),9))
							Case "y/m/d"
								SearchContents = Replace(SearchContents,Match.value,FormatDate(rsList("Tim"),10))
							Case "m/d"
								SearchContents = Replace(SearchContents,Match.value,FormatDate(rsList("Tim"),11))
						End Select
					Case fieldName
						SqlFieldSet = "SELECT * FROM [FieldSet] WHERE Field='"& fieldName &"' AND ChannelID="& ChannelID &" AND Recycle<>1 ORDER BY OrderNum ASC"
						Call Exec(RsFieldSet,SqlFieldSet,2)
						If RsFieldSet.BOF And RsFieldSet.EOF Then
							RsFieldSet.Close
							Set RsFieldSet = Nothing
						Else
							Pv_FieldType = RsFieldSet("FieldType")
							RsFieldSet.Close
							Set RsFieldSet = Nothing
							namelen = ParseArr(fieldArr)("len")
							sfieldName = rsList(fieldName)
							if not IsNul(sfieldName) then
								If Pv_FieldType="checkbox" Then
									SearchContents = Replace(SearchContents,Match.value,left(sfieldName,len(sfieldName)-1))
								Else
									if not IsNul(namelen) then
										namelen=cint(namelen)
										if len(sfieldName)>namelen then sfieldName=GetSubStr(sfieldName,namelen,False)
									end if
									SearchContents = Replace(SearchContents,Match.value,sfieldName)
								End If
							else
								SearchContents = Replace(SearchContents,Match.value,"")
							end if
						End If
					End Select
				Next
				Set Matches = nothing
				SearchContents=Replace(SearchContents,"{$Intro}",rsList("Intro"))
				SearchContents=Replace(SearchContents,"{$Content}",rsList("Content"))
				SearchContents=Replace(SearchContents,"{$Hits}",Hits)
				SearchContents=Replace(SearchContents,"{$Keyes}",rsList("Keyes"))
				SearchContents=Replace(SearchContents,"{$Inputer}",rsList("Inputer"))
				SearchContents=Replace(SearchContents,"{$Author}",rsList("Author"))
				SearchContents=Replace(SearchContents,"{$Subtitle}",rsList("Subtitle"))
				SearchContents=Replace(SearchContents,"{$Subheading}",rsList("Subheading"))
				Sql="select * from CopyFrom where ChannelID=" & ChannelID & " and SourceName='" & rsList("CopyFrom") & "'"
				Call Exe_Conn(Rs,Sql,3)
				If Rs.BOF And Rs.EOF Then
					Rs.Close
					Set Rs = Nothing
					CopyFrom = "<a href=""" & SiteUrl & """ target=""_blank"">" & rsList("CopyFrom") & "</a>"
				Else
					CopyFrom = "<a href=""" & Rs("SourceUrl") & """ target=""_blank"">" & Rs("SourceName") & "</a>"
					Rs.Close
					Set Rs = Nothing
				End If
				SearchContents=Replace(SearchContents,"{$CopyFrom}",CopyFrom)
				SearchContents=SearchContents&"</td>" & VbCrlf
				if (ji mod 1 = 0) Then SearchContents=SearchContents&"</tr>" & VbCrlf
				ji=ji+1
				iCount = iCount + 1
				If iCount >= MaxPerPage Then Exit Do
				rsList.MoveNext
			Loop
			rsList.Close
			Set rsList = Nothing
			if totalPut < 1 Then SearchContents=SearchContents&"</tr>" & VbCrlf
			if (totalPut mod 1 = 1) Then SearchContents=SearchContents&"</tr>" & VbCrlf
			SearchContents=SearchContents&"</table>"
			If ChannelIsCreateHtml = True Then
				Body=ShowPage_Html(InstallDir & ChannelDir & "/" & HtmlFileDir, 0, ChannelHtmlExtName, "", totalPut, MaxPerPage, CurrentPage, True, True, ChannelUnit & ChannelTit)
			Else
				Body=ShowPage(strFileName, totalPut, MaxPerPage, CurrentPage, True, True, ChannelUnit & ChannelTit, True)
			End If
		End If
		HtmlContent = Replace(HtmlContent,lablez & SearchContent&"[/Repeat]",SearchContents)
		HtmlContent = Replace(HtmlContent,"{$ClassID}",Cid)
		HtmlContent = Replace(HtmlContent,"{$more}",mores)
		HtmlContent = Replace(HtmlContent,"{$ClassName}", ClassNames)
		HtmlContent = Replace(HtmlContent,"{$Keyword}", Keyword)
		HtmlContent = Replace(HtmlContent,"{$ShowPage}",Body)
		HtmlContent = Replace(HtmlContent,"{$ChannelID}",ChannelID)
		HtmlContent = Replace(HtmlContent,"{$ChannelTit}",ChannelTit)
		HtmlContent = Replace(HtmlContent,"{$ChannelDir}",ChannelDir)
		HtmlContent = Replace(HtmlContent,"{$ChannelName}",ChannelName)
		HtmlContent = Replace(HtmlContent,"{$ChannelUnit}",ChannelUnit)
		HtmlContent = ReplaceHtml(HtmlContent)
		HtmlContent = Html.ReadClass(HtmlContent)
		HtmlContent = Html.ReadClassName(HtmlContent)
		HtmlContent = Html.ReadChannelList(HtmlContent)
		HtmlContent = Html.ReadChannelPic(HtmlContent)
		HtmlContent = Html.ReadChannelFlash(HtmlContent)
		HtmlContent = Html.ReadChannelFlashqq(HtmlContent)
		HtmlContent = ReHtml(HtmlContent)
	Else
		HtmlContent = ChannelTemplate(Mobanid,Skinid,ChannelID)
		If Instr(HtmlContent,"[Repeat]") > 0 Then
			lablez = "[Repeat]"
		Else
			HtmlContent = Replace(HtmlContent,"{$ClassName}", ClassNames)
			HtmlContent = ReplaceHtml(HtmlContent)
			HtmlContent = Html.ReadClass(HtmlContent)
			HtmlContent = Html.ReadClassName(HtmlContent)
			HtmlContent = Html.ReadChannelList(HtmlContent)
			HtmlContent = Html.ReadChannelPic(HtmlContent)
			HtmlContent = Html.ReadChannelFlash(HtmlContent)
			HtmlContent = Html.ReadChannelFlashqq(HtmlContent)
			HtmlContent = ReHtml(HtmlContent)
			Channel_Search = HtmlContent
			Exit Function
		End If
		SearchContent = CutFixContent(HtmlContent,lablez,"[/Repeat]",0)
		HtmlContent = Replace(HtmlContent,lablez & SearchContent&"[/Repeat]",SearchContents)
		HtmlContent = Replace(HtmlContent,"{$ClassID}",Cid)
		HtmlContent = Replace(HtmlContent,"{$more}",mores)
		HtmlContent = Replace(HtmlContent,"{$ClassName}", ClassNames)
		HtmlContent = Replace(HtmlContent,"{$Keyword}", "在这里搜索...")
		HtmlContent = Replace(HtmlContent,"{$ShowPage}",Body)
		HtmlContent = Replace(HtmlContent,"{$ChannelID}",ChannelID)
		HtmlContent = Replace(HtmlContent,"{$ChannelTit}",ChannelTit)
		HtmlContent = Replace(HtmlContent,"{$ChannelDir}",ChannelDir)
		HtmlContent = Replace(HtmlContent,"{$ChannelName}",ChannelName)
		HtmlContent = Replace(HtmlContent,"{$ChannelUnit}",ChannelUnit)
		HtmlContent = ReplaceHtml(HtmlContent)
		HtmlContent = Html.ReadClass(HtmlContent)
		HtmlContent = Html.ReadClassName(HtmlContent)
		HtmlContent = Html.ReadChannelList(HtmlContent)
		HtmlContent = Html.ReadChannelPic(HtmlContent)
		HtmlContent = Html.ReadChannelFlash(HtmlContent)
		HtmlContent = Html.ReadChannelFlashqq(HtmlContent)
		HtmlContent = ReHtml(HtmlContent)
	End If
	Channel_Search = HtmlContent
End Function

'****************************************************************
'函 数 名：GetSpecialPosition(ByVal strContent,ByVal BeginPoint,ByVal MaxCharperPage)
'作    用：解决把分页点放到了<img ,<p , <li等之间
'参    数：strContent 文章内容 BeginPoint 分页开始点 MaxCharperPage 每页字数
'****************************************************************
Private Function GetSpecialPosition(ByVal strContent, ByVal BeginPoint, ByVal MaxCharPerPage)
	Dim strTemp
	regEx.Pattern = "^(([^<]*>)[^<]{0,100})(?:<p|<img|<br|<li)*"
	strTemp = Right(strContent, Len(strContent) - BeginPoint)
	Set Matches = regEx.Execute(strTemp)
	If Matches.Count > 0 Then
		GetSpecialPosition = BeginPoint + Len(Matches(0).SubMatches(1)) + 1
	Else
		GetSpecialPosition = BeginPoint
	End If
End Function

'=================================================
'函 数 名：AutoPagination
'作    用：采用自动分页方式显示文章具体的内容
'参    数：无
'=================================================
Private Function AutoPagination(strTempContent,MaxCharPerPage,HtmlFileUrl)
	Dim lContent, ContentLen, MaxPerPage, lngBound
	Dim BeginPoint, EndPoint
	ContentLen = Len(strTempContent)
	If MaxCharPerPage <= 100 Or ContentLen <= MaxCharPerPage Or InStr(LCase(strTempContent), "<table") > 0 Or InStr(LCase(strTempContent), "</table>") > 0 Then
		AutoPagination = strTempContent & "</p>"
		Exit Function
	End If
	lContent = LCase(strTempContent)
	If InStr(lContent, "<table") > 0 And InStr(lContent, "</table>") > 0 Then
		AutoPagination = strTempContent & "</p>"
		Exit Function
	End If
	totalPage = ContentLen \ MaxCharPerPage
	If MaxCharPerPage * totalPage < ContentLen Then
		totalPage = totalPage + 1
	End If
	If CurrentPage < 1 Then CurrentPage = 1
	If CurrentPage > totalPage Then CurrentPage = totalPage
	If CurrentPage = 1 Then
		BeginPoint = 1
	Else
		BeginPoint = MaxCharPerPage * (CurrentPage - 1)
		BeginPoint = GetSpecialPosition(strTempContent, BeginPoint, MaxCharPerPage) '防止把拆分Html代码，返回新的位置
	End If
	If CurrentPage = totalPage Then
		EndPoint = ContentLen
	Else
		EndPoint = MaxCharPerPage * CurrentPage
		If EndPoint >= ContentLen Then
			EndPoint = ContentLen
		Else
			EndPoint = GetSpecialPosition(strTempContent, EndPoint, MaxCharPerPage)
		End If
	End If
	If EndPoint < BeginPoint Then EndPoint = BeginPoint
	AutoPagination = Mid(strTempContent, BeginPoint, EndPoint - BeginPoint) & "</p>" & GetContentPages(totalPage, CurrentPage, HtmlFileUrl)
End Function

'=================================================
'函数名：ManualPagination
'作  用：采用手动分页方式显示文章具体的内容
'参  数：无
'=================================================
Private Function ManualPagination(strTempContent,HtmlFileUrl)
	Dim strTemp
	Dim i
	Dim HasPageTitle
	i = 1
	strTemp = ""
	HasPageTitle = False
	regEx.MultiLine = False
	regEx.Pattern = "\[NextPage(.*?)\]"
	Set Matches = regEx.Execute(strTempContent)
	For Each Match In Matches
		If i = 1 Then
			If Match.SubMatches(0) <> "" Then
				If NoHtml(Left(strTempContent, InStr(strTempContent, Match.SubMatches(0)))) <> "" Then
					strTempContent = Code_Replace(strTempContent, Match.Value, "") '去掉第一个匹配的[NextPage 分页标题]
					strTemp = "第 1 页：" & Trim(Match.SubMatches(0))
				Else
					strTemp = "第 1 页：$$$第 2 页：" & Trim(Match.SubMatches(0))
				i = i + 1
				End If
				HasPageTitle = True
			Else
				strTemp = "第 1 页：$$$第 2 页："
				i = i + 1
			End If
		Else
			If Match.SubMatches(0) <> "" Then
				strTemp = strTemp & "$$$第 " & i & " 页：" & Trim(Match.SubMatches(0))
				HasPageTitle = True
			Else
				strTemp = strTemp & "$$$第 " & i & " 页："
			End If
		End If
		i = i + 1
	Next
	regEx.MultiLine = True
	strTempContent = regEx.Replace(strTempContent, "[NextPage]")  '将[NextPage 分页标题]替换成[NextPage]
	If HasPageTitle = True Then
		strContentPageTitleArr = strTemp
	Else
		strContentPageTitleArr = ""
	End If
	Dim arrContent
	If InStr(strTempContent, "[NextPage]") <= 0 Then
		ManualPagination = strTempContent & "</p>"
		Exit Function
	End If
	arrContent = Split(strTempContent, "[NextPage]")
	totalPage = UBound(arrContent) + 1
	If CurrentPage < 1 Then CurrentPage = 1
	If CurrentPage > totalPage Then CurrentPage = totalPage
	ManualPagination = arrContent(CurrentPage - 1) & "</p>" & GetContentPages(totalPage, CurrentPage, HtmlFileUrl)
End Function

'**************************************************
'函数名：GetContentPages
'作  用：显示"上一页 下一页"等信息
'参  数：totalPage ----总数量
'        CurrentPage ----当前页
'        HtmlFileUrl  ----链接地址
'返回值："上一页 下一页"等信息的HTML代码
'**************************************************
Private Function GetContentPages(totalPage, CurrentPage, HtmlFileUrl)
	Dim strPages
	Dim tmpArticleUrl
	Dim i
	Dim ShowPageNum '每页显示的页数
	Dim startFlag, endFlag '分页的开始结束标记
	ShowPageNum = 10
	If totalPage > ShowPageNum Then
		If (CurrentPage Mod ShowPageNum) <> 0 Then
			startFlag = (CurrentPage \ ShowPageNum) * ShowPageNum + 1
			endFlag = startFlag + ShowPageNum - 1
		Else
			startFlag = CurrentPage - ShowPageNum + 1
			endFlag = CurrentPage
		End If
	Else
		startFlag = 1
		endFlag = totalPage
	End If
	If endFlag > totalPage Then
		endFlag = totalPage
	End If
	
	tmpArticleUrl = Left(HtmlFileUrl, InStrRev(HtmlFileUrl, ".", -1, vbBinaryCompare) - 1)
	strPages = strPages & "<p align='center'><b>"
	If CurrentPage > 1 Then
		If ChannelIsCreateHtml = True Then
			If CurrentPage > 2 Then
				If CurrentPage > ShowPageNum And CurrentPage <= totalPage And startFlag > 1 Then
					strPages = strPages & "<a href='" & tmpArticleUrl & "_" & startFlag - 1 & ChannelHtmlExtName & "'>&nbsp;&lt;&lt;&nbsp;</a>"
				End If
				strPages = strPages & "<a href='" & tmpArticleUrl & "_" & CurrentPage - 1 & ChannelHtmlExtName & "'>上一页</a>&nbsp;&nbsp;"
			Else
				strPages = strPages & "<a href='" & tmpArticleUrl & ChannelHtmlExtName & "'>上一页</a>&nbsp;&nbsp;"
			End If
		Else
			If CurrentPage > ShowPageNum And CurrentPage <= totalPage Then
				strPages = strPages & "<a href='" & strFileName & "?id=" & Vid & "&Page=" & startFlag - 1 & "' >&nbsp;&lt;&lt;&nbsp;</a>"
			End If
			strPages = strPages & "<a href='" & strFileName & "?id=" & Vid & "&Page=" & CurrentPage - 1 & "'>上一页</a>&nbsp;&nbsp;"
		End If
	End If

	For i = startFlag To endFlag
		If i = CurrentPage Then
			strPages = strPages & "<font color='red'>[" & CStr(i) & "]</font>&nbsp;"
		Else
			If ChannelIsCreateHtml = True Then
				If i > 1 Then
					strPages = strPages & "<a href='" & tmpArticleUrl & "_" & i & ChannelHtmlExtName & "'>[" & i & "]</a>&nbsp;"
				Else
					strPages = strPages & "<a href='" & tmpArticleUrl & ChannelHtmlExtName & "'>[" & i & "]</a>&nbsp;"
				End If
			Else
				strPages = strPages & "<a href='" & strFileName & "?id=" & Vid & "&Page=" & i & "'>[" & i & "]</a>&nbsp;"
			End If
		End If
	Next
	If endFlag < totalPage Then
		strPages = strPages & " ... "
	End If
	If CurrentPage < totalPage Then
		If ChannelIsCreateHtml = True Then
			strPages = strPages & "<a href='" & tmpArticleUrl & "_" & CurrentPage + 1 & ChannelHtmlExtName & "'>下一页</a> "
			If totalPage > ShowPageNum And endFlag < totalPage Then
				strPages = strPages & "<a href='" & tmpArticleUrl & "_" & endFlag + 1 & ChannelHtmlExtName & "'>&nbsp;&gt;&gt;&nbsp;</a>"
			End If
		Else
			strPages = strPages & "&nbsp;<a href='" & strFileName & "?id=" & Vid & "&Page=" & CurrentPage + 1 & "'>下一页</a>"
			If totalPage > endFlag Then
				strPages = strPages & "<a href='" & strFileName & "?id=" & Vid & "&Page=" & endFlag + 1 & "'>&nbsp;&gt;&gt;&nbsp;</a>"
			End If
		End If
	End If
	strPages = strPages & "</b></p>"
	GetContentPages = strPages
End Function
%>